home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # syms - list symbols of a specified type in an object or archive
- #
- # Michael Gold, Silicon Graphics Computer Systems, June 1994
- #
- # Given one or more objects and a section, syms lists all symbols
- # from that section for each input object. The optional section
- # should be the letter from the Berkeley format nm(1) output. The
- # default is 'T', which corresponds to External Text, unless the
- # script is invoked as "undef", in which case the default is 'U'
- # (External undefined).
- #
- # If any named object is not found, the script searched for a
- # corresponding shared object or archive in /usr/lib. For
- # instance, "syms Xm" will search for ./Xm, /usr/lib/libXm.so,
- # and /usr/lib/libXm.a until one is found.
- #
- # All sections listed in nm(1) are supported.
- #
-
- libdir=/usr/lib
- field=T
- cmd=`basename $0`
-
- usage() {
- echo "usage: $cmd [-NTtDdBbAaUGgSsRrCEVIbXPFo] file1 file2 ..."
- exit 1
- }
-
- if [ $# = 0 ]; then
- usage
- fi
-
- if [ "$cmd" = "undef" ]; then
- field=U
- fi
-
- while getopts NTtDdBbAaUGgSsRrCEVIbXPFo c; do
- case $c in
- N|T|t|D|d|B|b|A|a|U|G|g|S|s|R|r|C|E|V|I|b|X|P|F|o) field=$c;;
- \?) usage;;
- esac
- done
- shift `expr $OPTIND - 1`
-
- for i in $*; do
- if [ -f "$i" ]; then
- file=$i
- elif [ -f $libdir/lib$i.so ]; then
- file=$libdir/lib$i.so
- elif [ -f $libdir/lib$i.a ]; then
- file=$libdir/lib$i.a
- else
- echo "$i not found"
- file=""
- fi
-
- if [ -n "$file" ]; then
- nm -Bo $file \
- | nawk -v field=$field '{ if ($3 == field) print $1 "\t" $4 " " $5 }'\
- | sort
- fi
- done
-
-